﻿using log4net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace S7Simulate
{
    public class Log4NetHelper
    {
        private static ILog infologHelper = LogManager.GetLogger("loginfo");

        private static ILog debuglogHelper = LogManager.GetLogger("logdebug");

        private static ILog errorlogHelper = LogManager.GetLogger("logerror");

        private static string GetDateTime()
        {
            return DateTime.Now.ToString() + "." + DateTime.Now.Millisecond;
        }

        private static void InitHelper()
        {
        }

        public static void Info(string msg)
        {
            InitHelper();
            if (!string.IsNullOrEmpty(msg))
            {
                infologHelper.Info("[Info] [" + GetDateTime() + "] " + msg);
            }
        }

        public static void Debug(string msg)
        {
            InitHelper();
            if (!string.IsNullOrEmpty(msg))
            {
                debuglogHelper.Debug("[Debug] [" + GetDateTime() + "] " + msg);
            }
        }

        public static void Error(string msg)
        {
            InitHelper();
            if (!string.IsNullOrEmpty(msg))
            {
                errorlogHelper.Error("[Error] [" + GetDateTime() + "] " + msg);
            }
        }
    }
}
